export default function (LoadingConstructor) {
  return {
    bind(el, binding) {
      el.style.position = 'relative'
      const instance = new LoadingConstructor({
        el: document.createElement('div'),
        data: {
          visible: binding.value
        }
      })
      el.instance = instance
      el.appendChild(instance.$el)
    },
    update(el, binding) {
      el.instance.visible = binding.value
    },
    unbind(el) {
      el.removeChild(el.instance.$el)
      el.instance.$destroy()
    }
  }
}
